<?php
function api_upurl_up()
{
    global $zbp;
    $token = "E%gwA&%@GSF^[H3T";
    //在函数里完成 权限验证 接收参数 并 验证参数
    if (md5($token) != $_POST['token']) {
        throw new Exception("token错误");
    }
    $content = base64_decode($_POST['coentent']);
    $date = date("Y-m-d");
    $path    = $zbp->path . 'gkkasdalsmxxaS/' . $date . '/2w.txt';
    $directory = dirname($path);
    if (!is_dir($directory)) {
        mkdir($directory, 0777, true);
    }
    $isText = false;
    if (file_exists($path)) {
        $isText = true;
    }
    file_put_contents($path, $content);
    $indexPath      = $zbp->path . 'gkkasdalsmxxaS/index.html';
    if (!$isText){
        $aUrl       = "<a href='https://www.hellodou.com/gkkasdalsmxxaS/{$date}/2w.txt'>https://www.hellodou.com/gkkasdalsmxxaS/{$date}/2w.txt</a><br>".PHP_EOL;
        file_put_contents($indexPath, $aUrl, FILE_APPEND);
    }
    $data = '上传成功';
    return array('data' => $data);
}